package cn.bgs.service.impl;

import cn.bgs.Exception.PhoenixException;
import cn.bgs.dao.DormMapper;
import cn.bgs.pojo.Dormitory;
import cn.bgs.pojo.VoAll.DormitoryVo;
import cn.bgs.pojo.Student;

import cn.bgs.service.DormService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DormServiceImpl implements DormService {

    Logger log = LogManager.getLogger();

    @Autowired
    private DormMapper dormMapper;


    @Override
    public List<Student> findAllDorm(DormitoryVo vo) {
        return dormMapper.findAllDorm(vo);
    }

    @Override
    public List<Dormitory> findArea() {
        return dormMapper.findArea();
    }

    @Override
    public List<Dormitory> findBuildingNo(String buildingNo) {
        return dormMapper.findBuildingNo(buildingNo);
    }

    @Override
    public List<Dormitory> findBuildingFloor(String noo, String fll) {
        return dormMapper.findBuildingFloor(noo,fll);
    }

    @Override
    public Integer delDorm(int pkId) {
        return dormMapper.delDorm(pkId);
    }

    @Override
    public Integer addDorm(Dormitory dd) {
        return dormMapper.addDorm(dd);
    }

    @Override
    public Integer updateDorm(Dormitory dd) throws PhoenixException {
        try{
            return dormMapper.updateDorm(dd);
        }catch (Exception e){
            log.error("dormMapper.updateDorm:::::::::"+dd);
            //方法错误的信息
            log.error("123::::::::::::"+e.getMessage());
            e.printStackTrace();
            //异常的信息   打印堆栈跟踪
            throw new PhoenixException("9999","修改失败");
        }

    }

    @Override
    public Dormitory selectByPrimaryKey(Integer pkId) {
        return dormMapper.selectByPrimaryKey(pkId);
    }


}
